/**
 * 新增修改完成调用 modalFormOk方法 编辑弹框组件ref定义为modalForm
 * 高级查询按钮调用 superQuery方法  高级查询组件ref定义为superQueryModal
 * data中url定义 list为查询列表  delete为删除单条记录  deleteBatch为批量删除
 */
// import { filterObj } from '@/utils/util';
import { deleteAction, getAction,downFile,getFileAccessHttpUrl } from '@/api/manage'
import Vue from 'vue'
// import { ACCESS_TOKEN } from "@/store/mutation-types"

export const JeecgListMixin = {
    data(){
        return {
            //token header
            
            /* 查询条件-请不要在queryParam中声明非字符串值的属性 */
            queryParam: {},
            /* 数据源 */
            dataSource:[],
            /* 分页参数 */
            ipagination:{
                current: 1,
                pageSize: 10,
                pageSizeOptions: ['10', '20', '30'],
                showTotal: (total, range) => {
                    return range[0] + "-" + range[1] + " 共" + total + "条"
                },
                showQuickJumper: true,
                showSizeChanger: true,
                total: 0
            },
            tokenHeader:{},
            epagination:{
                current: 1,
                pageSize: 10,
                pageSizeOptions: ['10', '20', '30'],
                showTotal: (total, range) => {
                    return range[0] + "-" + range[1] + " 共" + total + "条"
                },
                showQuickJumper: true,
                showSizeChanger: true,
                total: 0
            },
            /* 排序参数 */
            isorter:{
                column: 'Ts',
                order: 'desc',
            },
            columnsCopy:[],
            /* 筛选参数 */
            filters: {},
            /* table加载状态 */
            loading:false,
            /* table选中keys*/
            selectedRowKeys: [],
            selectedRowKeys2:[],
            selectionRows2:[],
            /* table选中records*/
            selectionRows: [],
            /* 查询折叠 */
            toggleSearchStatus:false,
            /* 高级查询条件生效状态 */
            superQueryFlag:false,
            /* 高级查询条件 */
            superQueryParams: '',
            /** 高级查询拼接方式 */
            superQueryMatchType: 'and',
        }
    },
    created() {
        if(window.location.href.indexOf('CompanyRefinanceListWeb') !== -1) {
            let columnsStorage = localStorage.getItem('/CompanyRefinanceListWeb-table')
            if(!columnsStorage) {
                let data = ["Company_CompanyAbbr","Company_CompanyCode","RefinanceDate","RefinanceRound_Value","RefinanceAmt","Investors","Ts"]
                localStorage.setItem('/CompanyRefinanceListWeb-table', JSON.stringify(data))
            }
        }
        this.tokenHeader.tokenId = localStorage.getItem('token');
        if(!this.disableMixinCreated){
            console.log(' -- mixin created -- ')
            this.columnsCopy = [...(new Set(this.columns))]
            this.loadData();
            //初始化字典配置 在自己页面定义
            this.initDictConfig();
        }

        let userInfo = localStorage.getItem('userInfo')?JSON.parse(localStorage.getItem('userInfo')):{};
        if(Object.keys(userInfo).length == 0){
            return false;
        }
        let id = userInfo.userId;
        let param = {conditions:[]};
        param.conditions = [{
          "field":"Id",
          "operator":"=",
          "value":id
        }]
        this.$http.postAction('/user/queryRows',param).then((res) => {
            if (res.status == 1 && res.data && res.data.rows && 0 < res.data.rows.length) {
                let linkerStaff = res.data.rows[0];
                if(linkerStaff.UserRole !== '467050010672889856' && !this.noAdd){
                    this.handleAdd();
                }
            }
        })
    },
    methods:{
        chooseFields(columnData){
            this.columns = columnData;
            this.$forceUpdate();
        },
        loadData(arg) {
            if(!this.url.list){
                // this.$message.error("请设置url.list属性!")
                return
            }
            //加载数据 若传入参数1则加载第一页的内容
            if (arg === 1) {
                this.ipagination.current = 1;
            }
            var params = {}
            if (this.url.list === '/companyRefinance/queryRows') {
                params = this.getRefinanceParams(this.exportParam)
            } else {
                params = this.getQueryParams();//查询条件
                params.orders = [{field:'Ts',desc:true}]
            }
            this.loading = true;
            let urlList = this.url.list;
            
            if(this.url.list == '/baseRegion/queryRowsRegion1'){
                urlList = '/baseRegion/queryRows';
                if(this.queryParam.key){
                    params.conditions = [{
                      "field":"RegionType",
                      "operator":"=",
                      "value":1
                    },{
                      "field":"RegionName",
                      "operator":"like",
                      "value":this.queryParam.key
                    }]
                }else{
                    params.conditions.push({
                      "field":"RegionType",
                      "operator":"=",
                      "value":1
                    })
                }
            }else if(this.url.list == '/baseRegion/queryRowsRegion2'){
                urlList = '/baseRegion/queryRows';
                if(this.queryParam.key){
                    params.conditions = [{
                      "field":"RegionType",
                      "operator":"=",
                      "value":2
                    },{
                      "field":"RegionName",
                      "operator":"like",
                      "value":this.queryParam.key
                    }]
                }else{
                    params.conditions.push({
                      "field":"RegionType",
                      "operator":"=",
                      "value":2
                    })
                }
                
            }else if(this.url.list == '/baseRegion/queryRowsRegion3'){
                urlList = '/baseRegion/queryRows';
                if(this.queryParam.key){
                    params.conditions = [{
                      "field":"RegionType",
                      "operator":"=",
                      "value":3
                    },{
                      "field":"RegionName",
                      "operator":"like",
                      "value":this.queryParam.key
                    }]
                }else{
                    params.conditions.push({
                      "field":"RegionType",
                      "operator":"=",
                      "value":3
                    })
                }
                
            }else if(this.url.list == '/companyRefinance/queryRows'){
                // params.column = "RefinanceDate";
                // params.orders = [{field:'RefinanceDate',desc:true}]
            }else if(this.url.list == '/companyInteractive/queryRows'){
                // params.column = "RefinanceDate";
                params.orders = [{field:'InteractiveDate',desc:true}]
            }else if(this.url.list == '/userIdentification/queryRows'){
                // params.column = "RefinanceDate";
                params.orders = [{"field":"IdentificationStatus_Value","desc":false}]
            }else if(this.url.list == '/userEvent/queryRows'){
                params.orders = [{"field":params.column,"desc":params.order == 'asc'?false:true}] 
            }else if(this.url.list == '/companyVisit/queryRows'){
                params.orders = [{field:'VisitTime',desc:true}] 
            }else if(this.url.list == '/businessInteractive/queryRows'){
                params.selectFields = ["SupplierUser","Interactive_DemandTag","Interactive_InteractiveTheme","Supplier_SubPark_ParkName","Interactive_InteractiveDate","Interactive_SupplierNumber","Interactive_ExpiryDate","Interactive_Company_CompanyName","Supplier_CompanyName","Interactive_InteractiveNo","Interactive_PayableLin","Discount","PayableLin","CouponLin","PaidLin","PayDate","InteractiveStatus_Value","UpdateBy_Name","TradeDate","DemandUser_UserName","DemandUser_Job","DemandUser_Phone","Interactive_DemandDescription","Interactive_DemandDetail"]
            }
            this.$http.postAction(urlList, params).then((res) => {
                if (res.status == 1) {
                    this.dataSource = res.data.rows;
                    this.ipagination.total = res.data.totalCount;
                    console.log('dataSource', this.dataSource)
                }else{
                    this.$message.warning(res.message)
                }
                this.loading = false;
            })
        },
        initDictConfig(){
            console.log("--这是一个假的方法!")
        },
        handleSuperQuery(params, matchType) {
            //高级查询方法
            if(!params){
                this.superQueryParams=''
                this.superQueryFlag = false
            }else{
                this.superQueryFlag = true
                this.superQueryParams=JSON.stringify(params)
                this.superQueryMatchType = matchType
            }
            this.loadData(1)
        },
        getQueryParams() {
            //获取查询条件
            let sqp = {}
            if(this.superQueryParams){
                sqp['superQueryParams']=encodeURI(this.superQueryParams)
                sqp['superQueryMatchType'] = this.superQueryMatchType
            }
            var param = Object.assign(sqp, this.queryParam, this.isorter ,this.filters);
            // param.selectFields = this.getQueryField();
            param.PageIndex = this.ipagination.current;
            param.pageSize = this.ipagination.pageSize;
            param.conditions = [];
            if(this.queryParam.key){
                param.conditions = {
                    or:[]
                }
                this.columnsCopy.forEach((e)=>{
                    if(e.dataIndex && e.isKey){
                        let obj = {
                            "field":e.dataIndex,
                            "operator":"like",
                            "value":this.queryParam.key
                        }
                        param.conditions.or.push(obj);
                    }
                })
                if (window.location.href.indexOf('CompanyRefinanceListWeb') !== -1) {
                    param.conditions.or.push({
                            "field":"Company_CompanyName",
                            "operator":"like",
                            "value":this.queryParam.key
                        });
                }
            }
            if(this.queryParam.PhotoUrl){
                param.conditions = [];
                param.conditions.push({
                    "field":'PhotoUrl',
                    "operator":"like",
                    "value":'download'
                })
                if(this.queryParam.key){
                    let paramJson = {
                        logicRelation:"OR",
                        children:[]
                      }
                    this.columnsCopy.forEach((e)=>{
                        if(e.dataIndex && e.isKey){
                            let obj = {
                                "field":e.dataIndex,
                                "operator":"like",
                                "value":this.queryParam.key
                            }
                            paramJson.children.push(obj);
                        }
                    })
                    param.conditions.push(paramJson);
                }
            }
            if(this.queryParam.DataStatus || this.queryParam.DataStatus === 0){
                if(!param.conditions || !param.conditions.or){
                    param.conditions = {
                        or:[]
                    }
                }
                param.conditions.or.push({
                    "field":'DataStatus',
                    "operator":"=",
                    "value":this.queryParam.DataStatus
                })
            }
            return param;
        },
        getQueryField() {
            //TODO 字段权限控制
            var str = [];
            this.columns.forEach(function (value) {
                if(value.dataIndex){
                    str.push(value.dataIndex);
                }
            });
            return str;
        },

        onSelectChange(selectedRowKeys, selectionRows) {
            this.selectedRowKeys = selectedRowKeys;
            this.selectionRows = selectionRows;
        },
        onClearSelected() {
            this.selectedRowKeys = [];
            this.selectionRows = [];
        },
        onSelectChange2(selectedRowKeys, selectionRows) {
            this.selectedRowKeys2 = selectedRowKeys;
            this.selectionRows2 = selectionRows;
        },
        onClearSelected2() {
            this.selectedRowKeys2 = [];
            this.selectionRows2 = [];
        },
        searchQuery() {
            this.loadData(1);
        },
        superQuery() {
            this.$refs.superQueryModal.show();
        },
        searchReset() {
            this.queryParam = {}
            this.loadData(1);
        },
        batchDel: function () {
            if(!this.url.deleteBatch){
                this.$message.error("请设置url.deleteBatch属性!")
                return
            }
            if (this.selectedRowKeys.length <= 0) {
                this.$message.warning('请选择一条记录！');
                return;
            } else {
                var ids = "";
                for (var a = 0; a < this.selectedRowKeys.length; a++) {
                    ids += this.selectedRowKeys[a] + ",";
                }
                var that = this;
                this.$confirm({
                    title: "确认删除",
                    content: "是否删除选中数据?",
                    onOk: function () {
                        that.loading = true;
                        deleteAction(that.url.deleteBatch, {ids: ids}).then((res) => {
                            if (res.success) {
                                that.$message.success(res.message);
                                that.loadData();
                                that.onClearSelected();
                            } else {
                                that.$message.warning(res.message);
                            }
                        }).finally(() => {
                            that.loading = false;
                        });
                    }
                });
            }
        },
        handleSubmit: function (record) {
            if(!this.url.submit){
                this.$message.error("请设置url.submit属性!")
                return
            }
            var that = this;
            getAction(that.url.submit, {id: record.id}).then((res) => {
                if (res.success) {
                    that.$message.success(res.message);
                    that.loadData();
                } else {
                    that.$message.warning(res.message);
                }
            });
        },
        handleDelete: function (record) {
            if(!this.url.delete){
                this.$message.error("请设置url.delete属性!")
                return
            }
            var that = this;
            this.$http.postAction(that.url.delete, record).then((res) => {
                if (res.status == 1) {
                    that.$message.success('删除成功');
                    that.loadData();
                } else {
                    that.$message.warning(res.message);
                }
            });
        },
        handleDeleteById: function (record, id) {
            if(!this.url.delete){
                this.$message.error("请设置url.delete属性!")
                return
            }
            for(var key in record){
                if (key !== id){
                    delete record[key]
                }
            }
            var that = this;
            this.$http.postAction(that.url.delete, record).then((res) => {
                if (res.status == 1) {
                    that.$message.success('删除成功');
                    that.loadData();
                } else {
                    that.$message.warning(res.message);
                }
            });
        },
        handleInvalid: function (id) {
            if(!this.url.invalid){
                this.$message.error("请设置url.invalid属性!")
                return
            }
            var that = this;
            getAction(that.url.invalid, {id: id}).then((res) => {
                if (res.success) {
                    that.$message.success(res.message);
                    that.loadData();
                } else {
                    that.$message.warning(res.message);
                }
            }).catch((e)=>{
                that.$message.warning('作废失败');
            });
        },
        handleEdit: function (record,type) {
            this.$refs.modalForm.edit(record);
            this.$refs.modalForm.title = "编辑";
            if(type == 'detail'){
                sessionStorage.setItem('editType','detail')
                this.$refs.modalForm.title = "详情";
            }else if(type == 'reSubmit'){
                sessionStorage.setItem('editType','edit')
                this.$refs.modalForm.title = "重新提交";
            }else{
                sessionStorage.setItem('editType','edit')
            }
            this.$refs.modalForm.disableSubmit = false;
        },
        handleAdd: function () {
            this.$refs.modalForm.add();
            this.$refs.modalForm.title = "新增";
            sessionStorage.setItem('editType','add')
            this.$refs.modalForm.disableSubmit = false;
        },
        handleTableChange(pagination, filters, sorter) {
            //分页、排序、筛选变化时触发
            //TODO 筛选
            if (Object.keys(sorter).length > 0) {
                this.isorter.column = sorter.field;
                this.isorter.order = "ascend" == sorter.order ? "asc" : "desc"
            }
            this.ipagination = pagination;
            this.loadData();
        },
        handleToggleSearch(){
            this.toggleSearchStatus = !this.toggleSearchStatus;
        },
        // 给popup查询使用(查询区域不支持回填多个字段，限制只返回一个字段)
        getPopupField(fields){
            return fields.split(',')[0]
        },
        modalFormOk() {
            // 新增/修改 成功时，重载列表
            this.loadData();
        },
        handleDetail:function(record){
            this.$refs.modalForm.edit(record);
            this.$refs.modalForm.title="详情";
            this.$refs.modalForm.disableSubmit = true;
        },
        /* 导出 */
        handleExportXls2(){
            let paramsStr = encodeURI(JSON.stringify(this.getQueryParams()));
            let url = `${window._CONFIG['domianURL']}/${this.url.exportXlsUrl}?paramsStr=${paramsStr}`;
            window.location.href = url;
        },
        add0(m){
          return m < 10 ? '0' + m: m
        },
        formatTime(timestamp){
          var time = new Date(timestamp)    //先将时间戳转为Date对象，然后才能使用Date的方法
          var year = time.getFullYear(),
              month = time.getMonth() + 1 ,  //月份是从0开始的
              day = time.getDate(),
              hour = time.getHours(),
              minute = time.getMinutes(),
              second = time.getSeconds()
              //add0()方法在后面定义
          return  year+'-'+this.add0(month)+'-'+ this.add0(day)+' '+this.add0(hour)+':'+this.add0(minute) +':'+this.add0(second)
        },
        getRefinanceParams(extraParam, isExport){
            var params = this.getQueryParams();//查询条件
            if(this.url.list == '/companyRefinance/queryRows' && isExport){
                // params.column = "RefinanceDate";
                params.selectFields = ["CompanyRefinanceId","Company.CompanyAbbr","Company.CompanyName","Company.PrimaryIndustry.Industry","Company.Industry.Industry",
                "Company.SubIndustry","Company_IndustryTag","Company.CompanyBrief","RefinanceDate","RefinanceRound.Value","RefinanceAmt","Investor",
                "IsShareholderChanged","IsRegisteredAmtChanged","IsDisclose","Company.Province_RegionName","Company.RegisteredDistrict.RegionName","Company.IndustrialPark_IndustrialParkName","Company.RegisteredDate","Company.CompanyCode","Company.RegisteredAddress","Company.OfficeAddress"]
            }
            params.orders = [{field:'RefinanceDate',desc:true}]
            let orArr = []
            if (params.conditions.or) {
                orArr = params.conditions.or
            }
            
            let conditions = {
                "and": []
            }
            let selfTime = extraParam.selfTime
            let timeLength = extraParam.timeLength
            if (selfTime && !timeLength) {
                conditions.and = [{
                    field: 'RefinanceDate',
                    operator: '>=',
                    value: this.formatTime(Date.parse(new Date(selfTime[0])))
                },
                {
                    field: 'RefinanceDate',
                    operator: '<=',
                    value: this.formatTime(Date.parse(new Date(selfTime[1])))
                }]
            } else if (!selfTime && timeLength) {
                let nowDate = this.formatTime(Date.parse(new Date()))
                let startDate = this.formatTime(Date.parse(new Date()) - (timeLength * 24 * 3600 * 1000))
                conditions.and = [{
                    field: 'RefinanceDate',
                    operator: '>=',
                    value: startDate
                },
                {
                    field: 'RefinanceDate',
                    operator: '<=',
                    value: nowDate
                }]
            }
            if (extraParam.provinceId) {
                conditions.and.push({
                    field: 'Company_ProvinceId',
                    operator: '=',
                    value: extraParam.provinceId
                })
            }
            if (extraParam.cityId) {
                conditions.and.push({
                    field: 'Company_CityId',
                    operator: '=',
                    value: extraParam.cityId
                })
            }
            if (extraParam.districtId) {
                conditions.and.push({
                    field: 'Company_RegisteredDistrict',
                    operator: '=',
                    value: extraParam.districtId
                })
            }
            if (extraParam.primaryIndustryId) {
                conditions.and.push({
                    field: 'Company_PrimaryIndustryId',
                    operator: '=',
                    value: extraParam.primaryIndustryId
                })
            }
            if (extraParam.subIndustryId) {
                conditions.and.push({
                    field: 'Company_IndustryId',
                    operator: '=',
                    value: extraParam.subIndustryId
                })
            }
            if (extraParam.thirdIndustryId) {
                conditions.and.push({
                    field: 'Company_SubIndustryId',
                    operator: '=',
                    value: extraParam.thirdIndustryId
                })
            }
            if (extraParam.QualificationTag) {
                conditions.and.push({
                    field: 'Company_QualificationTag',
                    operator: 'like',
                    value: extraParam.QualificationTag
                })
            }
            if (extraParam.IndustrialParkId) {
                conditions.and.push({
                    field: 'Company_IndustrialParkId',
                    operator: '=',
                    value: extraParam.IndustrialParkId
                })
            }
            if (extraParam.SubParkId) {
                conditions.and.push({
                    field: 'Company_SubParkId',
                    operator: '=',
                    value: extraParam.SubParkId
                })
            }
            
            params.conditions = conditions
            if (orArr.length) {
                params.conditions.and.unshift({
                    "or": orArr
                })
            }
            let refinaceArr = []
            if (extraParam.refinanceRoundId && 0 < extraParam.refinanceRoundId.length) {
                extraParam.refinanceRoundId.forEach(item => {
                    refinaceArr.push({
                        field: 'RefinanceRound',
                        operator: '=',
                        value: item
                    })
                })
                // if (params.conditions.and.length && params.conditions.and[0].or) {
                //     params.conditions.and[0].or.push(...refinaceArr)
                // } else {
                //     params.conditions.and.unshift({
                //         "or": refinaceArr
                //     })
                // }
                params.conditions.and.unshift({
                    "or": refinaceArr
                })
                if (extraParam.districtId) {
                    conditions.and.push({
                        field: 'Company_RegisteredDistrict',
                        operator: '=',
                        value: extraParam.districtId
                    })
                }
            }
            delete params.column
            delete params.order
            if (isExport){
                delete params.pageSize
            }
            if (params.conditions.and && params.conditions.and.length === 0){
                delete params.conditions
            }
            return params
        },
        handleExportXlsSelf(fileName, extraParam){
            if(!fileName || typeof fileName != "string"){
                fileName = "导出文件"
            }
            let param = {...this.queryParam};
            if(this.selectedRowKeys && this.selectedRowKeys.length>0){
                param['selections'] = this.selectedRowKeys.join(",")
            }
            console.log("导出参数",param)
            var params = this.getRefinanceParams(extraParam, true)
            // var params = this.getQueryParams();//查询条件
            // if(this.url.list == '/companyRefinance/queryRows'){
            //     // params.column = "RefinanceDate";
            //     params.orders = [{field:'RefinanceDate',desc:true}]
            //     params.selectFields = ["CompanyRefinanceId","Company.CompanyAbbr","Company.CompanyName","Company.PrimaryIndustry.Industry","Company.Industry.Industry",
            //     "Company.SubIndustry","Company.QualificationTag","Company.CompanyBrief","RefinanceDate","RefinanceRound.Value","RefinanceAmt","Investor",
            //     "IsShareholderChanged","IsRegisteredAmtChanged","IsDisclose","Company.Province_RegionName","Company.RegisteredDistrict.RegionName","Company.IndustrialPark_IndustrialParkName","Company.RegisteredDate","Company.CompanyCode","Company.RegisteredAddress","Company.OfficeAddress"]
            // }
            // let orArr = []
            // if (params.conditions.or) {
            //     orArr = params.conditions.or
            // }
            
            // let conditions = {
            //     "and": []
            // }
            // let selfTime = extraParam.selfTime
            // let timeLength = extraParam.timeLength
            // if (selfTime && !timeLength) {
            //     conditions.and = [{
            //         field: 'RefinanceDate',
            //         operator: '>=',
            //         value: this.formatTime(Date.parse(new Date(selfTime[0])))
            //     },
            //     {
            //         field: 'RefinanceDate',
            //         operator: '<=',
            //         value: this.formatTime(Date.parse(new Date(selfTime[1])))
            //     }]
            // } else if (!selfTime && timeLength) {
            //     let nowDate = this.formatTime(Date.parse(new Date()))
            //     let startDate = this.formatTime(Date.parse(new Date()) - (timeLength * 24 * 3600 * 1000))
            //     conditions.and = [{
            //         field: 'RefinanceDate',
            //         operator: '>=',
            //         value: startDate
            //     },
            //     {
            //         field: 'RefinanceDate',
            //         operator: '<=',
            //         value: nowDate
            //     }]
            // }
            // if (extraParam.provinceId) {
            //     conditions.and.push({
            //         field: 'Company_ProvinceId',
            //         operator: '=',
            //         value: extraParam.provinceId
            //     })
            // }
            // if (extraParam.cityId) {
            //     conditions.and.push({
            //         field: 'Company_CityId',
            //         operator: '=',
            //         value: extraParam.cityId
            //     })
            // }
            // if (extraParam.districtId) {
            //     conditions.and.push({
            //         field: 'Company_RegisteredDistrict',
            //         operator: '=',
            //         value: extraParam.districtId
            //     })
            // }
            // if (extraParam.primaryIndustryId) {
            //     conditions.and.push({
            //         field: 'Company_PrimaryIndustryId',
            //         operator: '=',
            //         value: extraParam.primaryIndustryId
            //     })
            // }
            // if (extraParam.subIndustryId) {
            //     conditions.and.push({
            //         field: 'Company_IndustryId',
            //         operator: '=',
            //         value: extraParam.subIndustryId
            //     })
            // }
            // if (extraParam.thirdIndustryId) {
            //     conditions.and.push({
            //         field: 'Company_SubIndustryId',
            //         operator: '=',
            //         value: extraParam.thirdIndustryId
            //     })
            // }
            
            // params.conditions = conditions
            // if (orArr.length) {
            //     params.conditions.and.unshift({
            //         "or": orArr
            //     })
            // }
            // let refinaceArr = []
            // if (extraParam.refinanceRoundId && 0 < extraParam.refinanceRoundId.length) {
            //     extraParam.refinanceRoundId.forEach(item => {
            //         refinaceArr.push({
            //             field: 'RefinanceRound',
            //             operator: '=',
            //             value: item
            //         })
            //     })
            //     if (params.conditions.and.length && params.conditions.and[0].or) {
            //         params.conditions.and[0].or.push(...refinaceArr)
            //     } else {
            //         params.conditions.and.unshift({
            //             "or": refinaceArr
            //         })
            //     }
            //     if (extraParam.districtId) {
            //         conditions.and.push({
            //             field: 'Company_RegisteredDistrict',
            //             operator: '=',
            //             value: extraParam.districtId
            //         })
            //     }
            // }
            // delete params.column
            // delete params.order
            // delete params.pageSize
            console.log('downloadParam', JSON.stringify(params))
            downFile(this.url.exportXlsUrl,params).then((data)=>{
                if (!data) {
                    this.$message.warning("文件下载失败")
                    return
                }
                if (typeof window.navigator.msSaveBlob !== 'undefined') {
                    window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls')
                }else{
                    let url = window.URL.createObjectURL(new Blob([data.data],{type: 'application/vnd.ms-excel'}))
                    let link = document.createElement('a')
                    link.style.display = 'none'
                    link.href = url
                    link.setAttribute('download', fileName+'.xls')
                    document.body.appendChild(link)
                    link.click()
                    document.body.removeChild(link); //下载完成移除元素
                    window.URL.revokeObjectURL(url); //释放掉blob对象
                }
            })
        },
        handleExportXls(fileName, day){
            if(!fileName || typeof fileName != "string"){
                fileName = "导出文件"
            }
            let param = {...this.queryParam};
            if(this.selectedRowKeys && this.selectedRowKeys.length>0){
                param['selections'] = this.selectedRowKeys.join(",")
            }
            console.log("导出参数",param)
            var params = this.getQueryParams();//查询条件
            if(this.url.list == '/companyRefinance/queryRows'){
                // params.column = "RefinanceDate";
                params.orders = [{field:'RefinanceDate',desc:true}]
                params.selectFields = ["CompanyRefinanceId","Investor","RefinanceDate","Company.CompanyAbbr","Company.CompanyName","Company.CompanyCode","RefinanceRound.Value","CurrencyType.Value","RefinanceAmt","Company.CompanyBrief","Company.PrimaryIndustry.Industry","Company.Industry.Industry","Company.IndustryTag", "Company.RegisteredDistrict.RegionName","Company.RegisteredAddress","Company.OfficeAddress"]
            }
            let orArr = []
            if (params.conditions.or) {
                orArr = params.conditions.or
            }
            if (day) {

                let nowDate = this.formatTime(Date.parse(new Date()))
                let startDate = this.formatTime(Date.parse(new Date()) - (day * 24 * 3600 * 1000))
                params.conditions = {
                    "and": [
                        {
                            field: 'RefinanceDate',
                            operator: '>=',
                            value: startDate
                        },
                        {
                            field: 'RefinanceDate',
                            operator: '<=',
                            value: nowDate
                        }
                    ]
                }
                if (orArr.length) {
                    params.conditions.and.unshift({
                        "or": orArr
                    })
                }
            }
            delete params.column
            delete params.order
            delete params.pageSize
            downFile(this.url.exportXlsUrl,params).then((data)=>{
                if (!data) {
                    this.$message.warning("文件下载失败")
                    return
                }
                if (typeof window.navigator.msSaveBlob !== 'undefined') {
                    window.navigator.msSaveBlob(new Blob([data],{type: 'application/vnd.ms-excel'}), fileName+'.xls')
                }else{
                    let url = window.URL.createObjectURL(new Blob([data.data],{type: 'application/vnd.ms-excel'}))
                    let link = document.createElement('a')
                    link.style.display = 'none'
                    link.href = url
                    link.setAttribute('download', fileName+'.xls')
                    document.body.appendChild(link)
                    link.click()
                    document.body.removeChild(link); //下载完成移除元素
                    window.URL.revokeObjectURL(url); //释放掉blob对象
                }
            })
        },
        /* 导入 */
        handleImportExcel(info){
            if (info.file.status !== 'uploading') {
                console.log(info.file, info.fileList);
            }
            if (info.file.status === 'done') {
                if(info.file.response.status == -3002 || info.file.response.status == -3001 || info.file.response.status == -1){
                    this.$message.warning(info.file.response.message)
                    return
                }
                this.loadData()
                
            } else if (info.file.status === 'error') {
                this.$message.error(`文件上传失败: ${info.file.msg} `);
            }
        },
        /* 图片预览 */
        getImgView(text){
            if(text && text.indexOf(",")>0){
                text = text.substring(0,text.indexOf(","))
            }
            return getFileAccessHttpUrl(text)
        },
        /* 文件下载 */
        uploadFile(text){
            if(!text){
                this.$message.warning("未知的文件")
                return;
            }
            if(text.indexOf(",")>0){
                text = text.substring(0,text.indexOf(","))
            }
            let url = getFileAccessHttpUrl(text)
            window.open(url);
        },
    }

}